/**************************************************************************
 * @name: music.c
 * @brief: 这个是学习播放音频的代码案例
 * @date: 2025/02/10
 * @author: boluzs@163.com
 * @note:
 *          1.要有图形化界面
 *          2.通过输入字符控制音频的播放
 * @version: 1.0.0
 * @Copyright (c) 2025 by boluzs@163.com, All Rights Reserved.
 **************************************************************************/
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char const *argv[])
{

    for (;;)
    {
        int n = 0;
        int status = 0;
        printf("***************************************\n");
        printf("************** 1  播放 ****************\n");
        printf("************** 2  暂停 ****************\n");
        printf("************** 3  继续 ****************\n");
        printf("************** 4  结束 ****************\n");
        printf("***************************************\n");
        printf("请输入需要的操作按钮\n");
        n = scanf("%d", &status);
        if (n != 1)
            printf("输入的控制标识符错误！\n");
        while (getchar() != '\n')
            ;
        switch (status)
        {
        case 1:
            system("madplay ./demo1.mp3 &");
            break;
        case 2:
            system("killall -SIGSTOP madplay");
            break;
        case 3:
            system("killall -SIGCONT madplay");
            break;
        case 4:
            system("killall -SIGKILL madplay");
            break;
        default:
            break;
        }
    }
    return 0;
}
